package com.sinoglobal.wallet.adapter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.sinoglobal.wallet.R;
import com.sinoglobal.wallet.entity.W_WithdrawalMoneyEntity.RsEntity;

public class W_WithdrawalRecordAdapter extends W_SinoBaseSimpleAdapter<RsEntity>{

	public W_WithdrawalRecordAdapter(Context mContext) {
		super(mContext);
	}

	@Override
	public void findViews(Map<java.lang.String, View> widgets, int position, View convertView) {
		TextView recharg_record_title = (TextView) convertView.findViewById(R.id.recharg_record_title);
		TextView recharg_record_time = (TextView) convertView.findViewById(R.id.recharg_record_time);
		TextView recharg_record_money = (TextView) convertView.findViewById(R.id.recharg_record_money);
		TextView recharg_record_state = (TextView) convertView.findViewById(R.id.recharg_record_state);
		widgets.put("recharg_record_title", recharg_record_title);
		widgets.put("recharg_record_time", recharg_record_time);
		widgets.put("recharg_record_money", recharg_record_money);
		widgets.put("recharg_record_state", recharg_record_state);
	}
	

	@Override
	public void setValues(View convertView, ViewHolder holder, Map<String, View> widgets, int position) {
		TextView recharg_record_title = (TextView) widgets.get("recharg_record_title");
		TextView recharg_record_time = (TextView) widgets.get("recharg_record_time");
		TextView recharg_record_money = (TextView) widgets.get("recharg_record_money");
		TextView recharg_record_state = (TextView) widgets.get("recharg_record_state");
		
		RsEntity recharg_record = (RsEntity) getItem(position);

	     SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");  
		recharg_record_time.setText(sdf.format(new Date(recharg_record.getCreateDate())));
		if(null!=recharg_record.getCardSn()&&recharg_record.getCardSn().toCharArray().length>=4){
		recharg_record_title.setText(recharg_record.getBankName() + "("
				+ recharg_record.getCardSn().substring(recharg_record.getCardSn().toCharArray().length-4, recharg_record.getCardSn().toCharArray().length) + ")");
		}else{
			recharg_record_title.setText("该银行卡号已解绑");
		}
		if(recharg_record.getStatus().equals("0")){
			recharg_record_money.setTextColor(mContext.getResources().getColor(R.color.w_payPass_gray));
			recharg_record_state.setTextColor(mContext.getResources().getColor(R.color.w_payPass_gray));
			
			recharg_record_state.setText("失败");
			recharg_record_money.setText(recharg_record.getAmount()+"元");
		}else if(recharg_record.getStatus().equals("1")){
			recharg_record_money.setTextColor(mContext.getResources().getColor(R.color.w_yellow_color));
			recharg_record_state.setTextColor(mContext.getResources().getColor(R.color.w_yellow_color));
			recharg_record_state.setText("成功");
			recharg_record_money.setText(recharg_record.getAmount()+"元");
		}else if(recharg_record.getStatus().equals("3")){
			recharg_record_money.setTextColor(mContext.getResources().getColor(R.color.w_red_color2));
			recharg_record_state.setTextColor(mContext.getResources().getColor(R.color.w_red_color2));
			
			recharg_record_state.setText("处理中");
			recharg_record_money.setText(recharg_record.getAmount()+"元");
		}
	
	}

	@Override
	public View setAdapterLayout(LayoutInflater inflater, int position) {
		return inflater.inflate(R.layout.wallet_rechrecord_list_item_layout, null);
	}
	
}
